#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string.h>

using namespace std;

class Node
{
public:
	vector<int> child;
};

const int MAX = 1005;
Node nodes[MAX];
int flag[MAX];
queue< pair<int, int> > q;

int bfs(int k, int n)
{
	memset(flag, 0, sizeof(flag) + 5);
	while(!q.empty())
	{
		q.pop();
	}

	q.push(pair<int, int>(k, 0));
	flag[k] = 1;

	int temp;
	int count = 0;
	int depth = 1;
	pair<int, int> now;

	while(!q.empty())
	{
		++count;
		now = q.front();
		q.pop();
		depth = now.second;

		for(int i = 0;i<(int)nodes[now.first].child.size();++i)
		{
			temp = nodes[now.first].child[i];
			if(!flag[temp])
			{
				flag[temp] = 1;
				q.push(pair<int, int>(temp, depth + 1));
			}
		}
	}

	if(count >= n)
	{
		return depth;
	}
	else
		return -1;
}

void solve(int n)
{
	for(int i = 1;i<=n;i++)
	{
		nodes[i].child.clear();
	}

	int now, next;
	for(int i = 1;i<=n;i++)
	{
		scanf("%d", &now);

		for(int j = 0;j<now;j++)
		{
			scanf("%d", &next);
			nodes[i].child.push_back(next);
		}
	}

	int res = -1;
	int index = -1;
	int temp;

	for(int i = n;i>0;--i)
	{
		temp = bfs(i, n);
		if(temp > res)
		{
			index = i;
			res = temp;
		}
	}

	if(index > 0)
	{
		printf("%d\n%d\n", res, index);
	}
	else
	{
		printf("impossible\n");
	}
}
int main()
{
	int n;

	while(scanf("%d", &n) != EOF)
	{
		solve(n);
	}
}
